<?php

class UserIdentity extends CUserIdentity
{
    private $_id;
    public function authenticate()
    {
	$record=Users::model()->findByAttributes(array('email'=>$this->username));
	if($record===null)
            $this->errorCode=self::ERROR_USERNAME_INVALID;
        else if($record->password!==$record->get_password_with_salt($this->password,$record->salt))
            $this->errorCode=self::ERROR_PASSWORD_INVALID;
        else
        {
            $this->_id=$record->id;
            //$this->setState('email', $record->email);
            $this->setState('first_name', $record->first_name);
           // $this->username = $record->first_name.' '.$record->last_name;
            $this->errorCode=self::ERROR_NONE;
        }
        return !$this->errorCode;
    }

    public function getId()
    {
        return $this->_id;
    }

	
}